package com.kaibes.web.security.core;

import java.util.Collection;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

public class CheckAuthorityToken implements CheckAuthority {

	@Override
	public boolean hasAuthority(HttpServletRequest request, Authentication authentication, String authority) {
		Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
		for (GrantedAuthority temp : authorities) {
            if (authority.equals(temp.getAuthority())) {
                return true;
            }
        }
		return false;
	}

}
